/**
 * A Catapult figure. extends Tower.
 * @authors Itay Sorani, Nadav Ziv, Yonathan Zarsky
 */
package com.example.models.Towers;

import com.example.models.Tower;
import com.example.models.Unit;
import com.example.models.Units.DaVinciTank;
import com.example.models.Units.Goblin;
import com.example.models.Units.Phoneix;
import com.example.models.Units.Troll;

import android.content.Context;

public class Catapult extends Tower {

	private static final int CATAPULT_COST = 20;
	private static final int CATAPULT_RANGE = 10;
	private static final int CATAPULT_RATE = 4;
	private static final int CATAPULT_DAMAGE_AGAINST_PHONEIX = 12;
	private static final int CATAPULT_DAMAGE_AGAINST_DA_VINCI_TANK = 30;
	private static final int CATAPULT_DAMAGE_AGAINST_GOBLIN = 13;
	private static final int CATAPULT_DAMAGE_AGAINST_TROLL = 20;
	private static final String CATAPULT_NAME = "Catapult";
	private static final float CATAPULT_SHOT_VELOCITY = 2;
	private static final String CATAPULT_SHOT = "CatapultShot";
	
	/**
     * Constructs a new Catapult according to range, fire rate, name and cost.
     */
	public Catapult(Context context) {
		super(context);
		setRange(CATAPULT_RANGE);
		setRate(CATAPULT_RATE * 40);
		setName(CATAPULT_NAME);
		setCost(CATAPULT_COST);
		setShotVelocity(CATAPULT_SHOT_VELOCITY);
		setShotName(CATAPULT_SHOT);
	}

	/**
     * returns the damage according to the given unit
     */
	public int getDamage(Unit unit) {
		if (unit instanceof Phoneix) {
			return (CATAPULT_DAMAGE_AGAINST_PHONEIX);
		}
		if (unit instanceof DaVinciTank) {
			return (CATAPULT_DAMAGE_AGAINST_DA_VINCI_TANK);
		}
		if (unit instanceof Goblin) {
			return (CATAPULT_DAMAGE_AGAINST_GOBLIN);
		}
		if (unit instanceof Troll) {
			return (CATAPULT_DAMAGE_AGAINST_TROLL);
		}
		return (0);
	}
}
